package main

/*
链表求和
 */

func AddTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode  {
	if l1 == nil {
		return l2
	}
	if l2 == nil {
		return l1
	}
	result := &ListNode{}
	dump := result
	flag := 0
	if l1 != nil || l2 != nil || flag != 0 {
		temp := flag
		if l1 != nil {
			temp += l1.Val
			l1 = l1.Next
		}
		if l2 != nil {
			temp += l2.Val
			l2 = l2.Next
		}
		newNode := &ListNode{Val:temp % 10}
		flag = temp / 10
		result.Next = newNode
		result = newNode
	}
	return dump
}

func main() {
	
}
